package com.wbsxch.rabbit.receiver.utils;

import org.apache.http.HttpVersion;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;

import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Map;

public class HTTPClientUtil {

    public static String doGet(String url){
        return doGet(url,null);
    }

    public static String doGet(String url,Map<String,String> params){

        doGet(url,params,null);

        return null;
    }

    public static String doGet(String url,Map<String,String> params,Map<String,String> heads){

        return doGet(url,params,heads,"UTF-8");
    }

    public static String doGet(String url,Map<String,String> params,Map<String,String> heads,String characterSet){

        try(CloseableHttpClient httpClient = HttpClients.createDefault()) {
            HttpGet httpGet = new HttpGet();
            httpGet.setURI(new URI(url));
            heads.forEach((k,v)->{
                httpGet.setHeader(k,v);
            });
            CloseableHttpResponse response = httpClient.execute(httpGet);

        } catch (IOException e) {
            e.printStackTrace();
        } catch (URISyntaxException e) {
            e.printStackTrace();
        }
        return null;
    }
}
